//
//  PaperRecordCell.swift
//  Exam-iOS
//
//  Created by lishengfeng on 2018/3/24.
//  Copyright © 2018年 李胜锋. All rights reserved.
//

import Foundation
import SnapKit
import Then

class PaperRecordCell: UITableViewCell {
    var titleLabel: UILabel!
    var scoreLabel: UILabel!
    var dateLbale: UILabel!
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        setup()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setup()
    }
    
    public func set(title: String?, score: Int?, date: String?) {
        titleLabel.text = title
        dateLbale.text = date
        scoreLabel.text = "\(score ?? 0)分"
        
    }
    private func setup() {
        let containerView = UIView().then { (view) in
            view.clipsToBounds = true
            view.layer.borderColor = UIColor.lsf_color16(0xD3D3D3).cgColor
            view.layer.borderWidth = 0.5
            view.layer.cornerRadius = 4
            
            self.contentView.addSubview(view)
            view.snp.makeConstraints({ (maker) in
                maker.edges.equalTo(UIEdgeInsetsMake(10, 10, 0, 10))
            })
        }
        
        titleLabel = UILabel().then({ (label) in
            label.textColor = UIColor.black
            label.font = UIFont.systemFont(ofSize: 14)
            
            containerView.addSubview(label)
            label.snp.makeConstraints({ (maker) in
                maker.leading.equalTo(13)
                maker.top.equalTo(11)
                maker.trailing.equalTo(-124)
            })
        })
        
        
        
        dateLbale = UILabel().then({ (label) in
            label.textAlignment = .right
            label.font = UIFont.systemFont(ofSize: 12)
            label.textColor = UIColor.lsf_color16(0x9b9b9b)
            
            containerView.addSubview(label)
            label.snp.makeConstraints({ (maker) in
                maker.leading.equalTo(13)
                maker.top.equalTo(titleLabel.snp.bottom).offset(4)
                maker.bottom.equalTo(-15)
            })
        })
        
        
        scoreLabel = UILabel().then({ (label) in
            label.textAlignment = .right
            label.font = UIFont.systemFont(ofSize: 14)
            
            containerView.addSubview(label)
            label.snp.makeConstraints({ (maker) in
                maker.trailing.equalTo(-20)
                maker.centerY.equalToSuperview()
            })
        })
    }
}
